import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/login.vue'
import AdminHome from '../components/admin/home.vue'
import SellerHome from '../components/seller/home.vue'
import BuyerHome from '../components/buyer/home.vue'
import GoodList from '../components/buyer/goodlist.vue'

Vue.use(VueRouter)

const routes = [
	{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/login',
		component: Login
	},
	{
		path: '/admin/home',
		component: AdminHome,
		redirect: '/admin/welcome',
		children: [
			{
				path: '/admin/user',
				component: () => import('../components/admin/user.vue')
			},
			{
				path: '/admin/welcome',
				component: () => import('../components/admin/welcome.vue')
			},
			{
				path: '/admin/goodcar',
				component: () => import('../components/admin/goodcar.vue')
			},
			{
				path: '/admin/goodorder',
				component: () => import('../components/admin/goodorder.vue')
			},
			{
				path: '/admin/address',
				component: () => import('../components/admin/address.vue')
			},
			{
				path: '/admin/goodlist',
				component: () => import('../components/admin/goodlist.vue')
			},
			{
				path: '/admin/category',
				component: () => import('../components/admin/category.vue')
			},
		]
	},
	{
		path: '/seller/home',
		component: SellerHome,
		redirect: '/seller/welcome',
		children: [
			{
				path: '/seller/welcome',
				component: () => import('../components/seller/welcome.vue')
			},
			{
				path: '/seller/goodlist',
				component: () => import('../components/seller/goodlist.vue')
			},
			{
				path: '/seller/category',
				component: () => import('../components/seller/category.vue')
			},
			{
				path: '/seller/mine',
				component: () => import('../components/seller/mine.vue')
			},
		]
	},
	{
		path: '/buyer/home',
		component: BuyerHome,
		redirect: '/buyer/goodlist',
		children: [
			{
				path: '/buyer/mine',
				component: () => import('../components/buyer/mine.vue')
			},
			{
				path: '/buyer/goodlist/',
				component: GoodList
			},
			{
				path: '/buyer/detail',
				component: () => import('../components/buyer/detail.vue')
			},
			{
				path: '/buyer/goodcar',
				component: () => import('../components/buyer/goodcar.vue')
			},
			{
				path: '/buyer/order',
				component: () => import('../components/buyer/order.vue')
			},
			]
	},
	{
		path: '/register',
		component: () => import('../components/register.vue')
	},
]

const router = new VueRouter({
  routes
})

export default router
